package com.hyphenate.easeui.dao;

import android.database.sqlite.SQLiteDatabase;

import com.hyphenate.easeui.EaseConstant;
import com.hyphenate.easeui.model.GroupChatBean;
import com.hyphenate.easeui.model.ReplyImageInfo;
import com.hyphenate.easeui.model.TopicImageInfo;
import com.hyphenate.easeui.model.UserBean;

import java.util.Map;

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.AbstractDaoSession;
import de.greenrobot.dao.identityscope.IdentityScopeType;
import de.greenrobot.dao.internal.DaoConfig;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.

/**
 * {@inheritDoc}
 * 
 * @see de.greenrobot.dao.AbstractDaoSession
 */
public class DaoSession extends AbstractDaoSession {

    private final DaoConfig UserBeanDaoConfig;
    private final UserBeanDao UserBeanDao;
    private final DaoConfig GroupChatBeanConfig;
    private final GroupChatBeanDao GroupChatBeanDao;
    private final DaoConfig topicImageBeanConfig;
    private final TopicImageDao topicImageDao;
    private final DaoConfig replyImageBeanConfig;
    private final ReplyImageDao replyImageDao;

    public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
            daoConfigMap) {
        super(db);

        UserBeanDaoConfig = daoConfigMap.get(UserBeanDao.class).clone();

        UserBeanDaoConfig.initIdentityScope(type);

        UserBeanDao = new UserBeanDao(UserBeanDaoConfig, this);
        registerDao(UserBean.class, UserBeanDao);

        GroupChatBeanConfig= daoConfigMap.get(GroupChatBeanDao.class).clone();
        GroupChatBeanConfig.initIdentityScope(type);
        GroupChatBeanDao=new GroupChatBeanDao(GroupChatBeanConfig,this);
        registerDao(GroupChatBean.class, GroupChatBeanDao);

        topicImageBeanConfig= daoConfigMap.get(TopicImageDao.class).clone();
        topicImageBeanConfig.initIdentityScope(type);
        topicImageDao=new TopicImageDao(topicImageBeanConfig,this);
        registerDao(TopicImageInfo.class, topicImageDao);

        replyImageBeanConfig= daoConfigMap.get(ReplyImageDao.class).clone();
        replyImageBeanConfig.initIdentityScope(type);
        replyImageDao=new ReplyImageDao(replyImageBeanConfig,this);
        registerDao(ReplyImageInfo.class, replyImageDao);

    }
    
    public void clear(String name) {
        if(name.equals(EaseConstant.DB_NAME_CHAT))
        UserBeanDaoConfig.getIdentityScope().clear();
        else if(name.equals(EaseConstant.DB_NAME_GROUP))
        GroupChatBeanConfig.getIdentityScope().clear();
        else if(name.equals(EaseConstant.DB_NAME_TOPIC_IMAGE)){
            topicImageBeanConfig.getIdentityScope().clear();
        }else if(name.equals(EaseConstant.DB_NAME_REPLY_IMAGE)){
            replyImageBeanConfig.getIdentityScope().clear();
        }
    }

    public UserBeanDao getUserBeanDao() {
        return UserBeanDao;
    }

    public GroupChatBeanDao getGroupChatBeanDao() {
        return GroupChatBeanDao;
    }

    public TopicImageDao getTopicImageDao() {
        return topicImageDao;
    }

    public ReplyImageDao getReplyImageDao() {
        return replyImageDao;
    }
}
